package com.sgcc.ln.pmos.e_ln_order.presenter;

import android.text.TextUtils;

import com.blankj.utilcode.util.ToastUtils;
import com.sgcc.ln.pmos.common.base.BasePresenter;
import com.sgcc.ln.pmos.common.bean.BaseResponse;
import com.sgcc.ln.pmos.common.http.HttpInterConst;
import com.sgcc.ln.pmos.common.http.HttpRequestUtils;
import com.sgcc.ln.pmos.common.http.MvpNetCallback;
import com.sgcc.ln.pmos.e_ln_order.bean.EnergyByMonthDetailBean;
import com.sgcc.ln.pmos.e_ln_order.bean.IndentBean;
import com.sgcc.ln.pmos.e_ln_order.bean.OrderInfoOfTableBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageComparisonPriceDetailBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageComparisonSchemeDetailBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageInfoBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageInfoResAndBargBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageInfoResBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PackageOrdersBean;
import com.sgcc.ln.pmos.e_ln_order.bean.PriceDetailBean;
import com.sgcc.ln.pmos.e_ln_order.bean.SchemeResBean;
import com.sgcc.ln.pmos.e_ln_order.contract.OrderDetailsContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.View> implements OrderDetailsContract.Presenter {

    @Override
    public void orderCheck(String relationId, String membersId, String combId, String startDate, String endDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("membersId", membersId);
        params.put("combId", combId);
        params.put("startDate", startDate);
        params.put("endDate", endDate);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_QUOTA_CHECK, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if (response.isSuccess()) {
                        getView().orderCheckSuccess(relationId);
                    } else {
                        ToastUtils.showShort(response.getMsg());

                    }
                }

            }
        });
    }



    @Override
    public void beforeSubmit_check(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_BEFORESUBMIT, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
                ToastUtils.showShort("校验失败");
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if (response.isSuccess()) {
                        getView().orderCheckSuccess(relationId);
                    } else {
                        ToastUtils.showShort(response.getMsg());

                    }
                }

            }
        });
    }





    @Override
    public void getContractList(String relCode, String flag) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relCode", relCode);
        params.put("membersSdName", "");
        params.put("startTime", "");
        params.put("endTime", "");
        params.put("pageNum", 1);
        params.put("pageSize", 10);
        params.put("flag", flag);//订单传0 合约传1
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_INDENT_LIST, new MvpNetCallback<IndentBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(IndentBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().getContractList(response);
            }
        });
    }

    @Override
    public void cancelRelieveContract(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CANCELRELIEVECONTRACT, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().cancelRelieveContract(response);
            }
        });
    }

    /**
     * 备案补充协议-撤销
     *
     * @param relationId
     */
    @Override
    public void revokeSupplementContract(String relationId) {

        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.REVOKE_SUPPLEMENTCONTRACT,
                new MvpNetCallback<BaseResponse>(getView(), true) {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        super.onError(call, e, id);
                        // 失败回调 判断界面是否销毁
                        if (!isViewAttached()) {
                            return;
                        }
                    }

                    @Override
                    public void onResponse(BaseResponse response, int id) {
                        super.onResponse(response, id);
                        if (!isViewAttached()) {
                            return;
                        }
                        getView().cancelRelieveContract(response);
                    }
                });

    }

    /**
     * 约定电量
     *
     * @param relationId 订单ID
     */
    @Override
    public void getEnergyByMonthDetail(String relationId, String packageId, boolean isFirst) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        params.put("packageId", packageId);
        Map<String, String> headers = new HashMap<>();
        headers.put("CurrentRoute", "/pxf-phbsx-shop/#/frontDetail");
        HttpRequestUtils.getInstance().requestWithDiffHeaders(params, HttpInterConst.ORDER_GETENERGYBYMONTHDETAIL, new MvpNetCallback<EnergyByMonthDetailBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(EnergyByMonthDetailBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getEnergyByMonthDetail(response, isFirst);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }

            }
        }, headers);
    }

    /**
     * 约定电量（修改前后数据）
     *
     * @param relCode
     * @param monthDate
     */
    @Override
    public void queryOrderInfoOfTable(String relCode, String monthDate, String peType,String relationId,String combId) {
        Map<String, String> params = new HashMap<>();
        params.put("paramsRandom", "0.9760932495685792");
        params.put("relCode", relCode);
        params.put("dlFlag", "2");
        params.put("flag", "1");
        params.put("relationId", relationId);
        params.put("combId", combId);
        params.put("monthDate", monthDate);

        HttpRequestUtils.getInstance().requestGet(params, HttpInterConst.PLACE_QUERYORDERINFOOFTABLE, new MvpNetCallback<OrderInfoOfTableBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
            }

            @Override
            public void onResponse(OrderInfoOfTableBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().queryOrderInfoOfTable(response, peType);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }

            }
        });
    }

    /**
     * 合约下拉
     *
     * @param relationId
     */
    @Override
    public void getPackageOrders(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_GETPACKAGEORDERS, new MvpNetCallback<PackageOrdersBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
            }

            @Override
            public void onResponse(PackageOrdersBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getPackageOrders(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }

            }
        });
    }


    /**
     * 商品详情（月份）
     *
     * @param combId
     * @param relationId
     */
    @Override
    public void getPackageInfo(String combId, String relationId, String effectiveDate, String invalidDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("combId", combId);
        params.put("relationId", relationId);
        params.put("effectiveDate", effectiveDate);
        params.put("invalidDate", invalidDate);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.MALL_GETPACKAGEINFO, new MvpNetCallback<PackageInfoBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PackageInfoBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getPackageInfo(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 订单详情内容补充（对比售电公司数据）
     *
     * @param schemeId
     * @param relationId
     */
    @Override
    public void packageComparisonPriceDetailTwo(String schemeId, String relationId, boolean isMain) {
        Map<String, Object> params = new HashMap<>();
        params.put("schemeId", schemeId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_PACKAGECOMPARISONPRICEDETAILTWO, new MvpNetCallback<PackageComparisonPriceDetailBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PackageComparisonPriceDetailBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().packageComparisonPriceDetailTwo(response, isMain);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 电价列表（对比售电公司数据）
     *
     * @param schemeId
     * @param relationId
     */
    @Override
    public void packageComparisonSchemeDetailTwo(String schemeId, String relationId, boolean isMain) {
        Map<String, Object> params = new HashMap<>();
        params.put("schemeId", schemeId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_PACKAGECOMPARISONSCHEMEDETAILTWO, new MvpNetCallback<PackageComparisonSchemeDetailBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PackageComparisonSchemeDetailBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().packageComparisonSchemeDetailTwo(response, isMain);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 订单详情内容补充（不对比售电公司数据）
     *
     * @param schemeId
     * @param relationId
     */
    @Override
    public void getPriceDetail(String schemeId, String relationId, boolean isMain) {
        Map<String, Object> params = new HashMap<>();
        params.put("schemeId", schemeId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_GETPRICEDETAIL, new MvpNetCallback<PriceDetailBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PriceDetailBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getPriceDetail(response, isMain);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 电价列表（不对比售电公司数据）
     *
     * @param schemeId
     * @param relationId
     */
    @Override
    public void getSchemeRes(String schemeId, String relationId, boolean isMain) {
        Map<String, Object> params = new HashMap<>();
        params.put("schemeId", schemeId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_GETSCHEMERES, new MvpNetCallback<SchemeResBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(SchemeResBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getSchemeRes(response, isMain);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 协议下单对比结果
     *
     * @param packageId
     * @param relationId
     */
    @Override
    public void getPackageInfoResAndBarg(String packageId, String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("packageId", packageId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_GETPACKAGEINFORESANDBARG, new MvpNetCallback<PackageInfoResAndBargBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PackageInfoResAndBargBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getPackageInfoResAndBarg(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 结果内容（不对比售电公司数据）
     *
     * @param packageId
     * @param relationId
     */
    @Override
    public void getPackageInfoRes(String packageId, String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("packageId", packageId);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_GETPACKAGEINFORES, new MvpNetCallback<PackageInfoResBean>(getView(), false) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(PackageInfoResBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().getPackageInfoRes(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    /**
     * 备案补充协议-撤销
     * revokeSupplementContract
     */


    /**
     * 电价变更
     *
     * @param relationId //订单ID
     * @param packageId  //商品月份组合套餐ID
     * @param monthDate  //月份
     */
    @Override
    public void priceChange(String relationId, String packageId, String monthDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("packageId", packageId);
        params.put("monthDate", monthDate);
        params.put("relationId", relationId);
        params.put("_t", System.currentTimeMillis());
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_PRICE_CHANGE, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("200".equals(response.getCode())) {
                        getView().priceChange(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    @Override
    public void cancelBargain(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CANCELBARGAIN, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if (response.isSuccess()) {
                        getView().cancelBargainSuccess(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }
            }
        });
    }

    @Override
    public void userRejectBargain(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_USERREJECTBARGAIN, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if (response.isSuccess()) {
                        getView().userRejectBargainSuccess(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }

            }
        });
    }

    @Override
    public void beforeSubmit(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_IMMEDIATESUBMIT, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if (response.isSuccess()) {
                        getView().userRejectBargainSuccess(response);
                    } else {
                        if (TextUtils.isEmpty(response.getMsg())) {
                            ToastUtils.showShort(response.getMsg());
                        }
                    }
                }

            }
        });
    }

    @Override
    public void relieveContract(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_RELIEVECONTRACT, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().relieveContractSuccess(response);
            }
        });
    }

    @Override
    public void rejectPriceChange(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_REJECTPRICECHANGE, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().rejectPriceChange(response);
            }
        });
    }

    @Override
    public void confirmPriceChange(String relationId, String monthDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        params.put("monthDate", monthDate);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CONFIRMPRICECHANGE, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().confirmPriceChange(response);
            }
        });
    }

    @Override
    public void cancelPriceChange(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CANCELPRICECHANGE, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().cancelPriceChange(response);
            }
        });
    }

    @Override
    public void cancelPowerChange(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CANCELPOWERCHANGE, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().cancelPowerChange(response);
            }
        });
    }




    @Override
    public void cancelOrder(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_CANCELORDER, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().cancelOrderSuccess(response);
            }
        });
    }


    @Override
    public void applyForBargain(String relationId) {
        Map<String, Object> params = new HashMap<>();
        params.put("_t", System.currentTimeMillis());
        params.put("relationId", relationId);
        HttpRequestUtils.getInstance().request(params, HttpInterConst.ORDER_APPLAYBARGAIN, new MvpNetCallback<BaseResponse>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(BaseResponse response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().applyForBargainSuccess(response);
            }
        });
    }
}
